<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div>
        <button onclick="add()">添加</button>
        <!-- <button onclick="shanchu()">删除</button> -->
    </div>
</body>

</html>
<script>

    // let deleteId = 353;
    // function shanchu() {
    //     if (deleteId === 550) return;

    //     var myHeaders = new Headers();
    //     myHeaders.append("Token", "94643a9d-e93f-4b23-b4d9-e8630e377c79");
    //     myHeaders.append("Authorization", "{{token}}");
    //     myHeaders.append("User-Agent", "Apifox/1.0.0 (https://apifox.com)");
    //     myHeaders.append("Content-Type", "application/json");
    //     myHeaders.append("Accept", "*/*");
    //     myHeaders.append("Host", "10.243.18.202:8081");
    //     myHeaders.append("Connection", "keep-alive");

    //     var raw = JSON.stringify({
    //         "id": deleteId
    //     });

    //     var requestOptions = {
    //         method: 'POST',
    //         headers: myHeaders,
    //         body: raw,
    //         redirect: 'follow'
    //     };

    //     fetch("http://10.243.18.202:8081/api/tmx/removeResource", requestOptions)
    //         .then(response => response.text())
    //         .then(result => {
    //             deleteId = deleteId + 1
    //             shanchu()
    //             console.log(result)
    //         })
    //         .catch(error => console.log('error', error));

    // }



    let num = 320;
    function add() {
        // 500
        if (num === 500) return;
        console.log('num', num);
        var myHeaders = new Headers();
        myHeaders.append("Token", "94643a9d-e93f-4b23-b4d9-e8630e377c79");
        myHeaders.append("Authorization", "{{token}}");
        myHeaders.append("User-Agent", "Apifox/1.0.0 (https://apifox.com)");
        myHeaders.append("Content-Type", "application/json");
        myHeaders.append("Accept", "*/*");
        myHeaders.append("Host", "10.243.18.202:8081");
        myHeaders.append("Connection", "keep-alive");

        var raw = JSON.stringify({
            "number": "DSJ0" + num,
            "name": "DSJ0" + num,
            "deviceType": "2",
            "deviceModel": "",
            "type": "1",
            "id": "",
            "departmentId": 14
        });

        var requestOptions = {
            method: 'POST',
            headers: myHeaders,
            body: raw,
            redirect: 'follow'
        };


        fetch("http://10.243.18.202:8081/api/tmx/saveResource", requestOptions)
            .then(response => response.text())
            .then(result => {
                console.log(result)
                num = num + 1
                add()
            })
            .catch(error => {
                console.log('error', error)
                // nextStep()
                // num = num + 1
                // add()
            });

    }
</script>